/*
 * Licensed to the Apache Software Foundation (ASF) under one or more
 * contributor license agreements.  See the NOTICE file distributed with
 * this work for additional information regarding copyright ownership.
 * The ASF licenses this file to You under the Apache License, Version 2.0
 * (the "License"); you may not use this file except in compliance with
 * the License.  You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */


import static org.junit.Assert.*;
import org.junit.Test;

import junit.framework.TestCase;

public class UrlValidatorTest extends TestCase {
   UrlValidator url = new UrlValidator(null, null, UrlValidator.ALLOW_ALL_SCHEMES);
   
   private boolean printStatus = false;
   private boolean printIndex = false;//print index that indicates current scheme,host,port,path, query test were using.

   public UrlValidatorTest(String testName) {
      super(testName);
   }

   
   
   public void testManualTest()
   {
		@Test
		public void manual() {
			assertTrue(url.isValid("http://www.yahoo.com")); // normal domain
			assertTrue(url.isValid("https://mail.yahoo.com")); // subdomain
			assertTrue(url.isValid("http://www.yahoo.ca")); // two letter top level domain
			assertFalse(url.isValid("http://www.yahoo.ca/../")); // invalid directory name
			assertTrue(url.isValid("ftp://www.yahoo.ca")); // ftp
			assertFalse(url.isValid("http://www.yahoo")); // missing extension
			assertFalse(url.isValid("yahoo")); // single word
		}
   }
   
   
   public void partition_testing()
   {
	
		@Test
		public void partition_top_level(){
			assertTrue(url.isValid("http://www.yahoo.gov")); // gov
			assertTrue(url.isValid("http://www.yahoo.com")); // normal
			assertTrue(url.isValid("http://www.yahoo.tv")); // country code
			assertFalse(url.isValid("http://www.yahoo.zzzzzzzzzzzzzz"));  // length violation
			assertFalse(url.isValid("http://www.yahoo.")); // missing
			assertFalse(url.isValid("http://www.yahoo.456")); // numbers
		}
		
		@Test
		public void partition_protocol(){
			assertTrue(url.isValid("http://www.yahoo.com"));
			assertTrue(url.isValid("https://www.yahoo.com"));
			assertTrue(url.isValid("ftp://www.yahoo.com"));
			assertTrue(url.isValid("ftps://www.yahoo.com"));
			assertFalse(url.isValid("://www.yahoo.com"));
			assertFalse(url.isValid("bad data://www.yahoo.com"));
		}
		
		@Test
		public void partition_addon_domain(){
			assertTrue(url.isValid("http://www.yahoo.com")); // normal
			assertTrue(url.isValid("http://level1.com")); // level1
			assertTrue(url.isValid("http://level2.level1.yahoo.com")); // level2
			assertTrue(url.isValid("http://level3.level2.level1.yahoo.com")); // level3
			assertTrue(url.isValid("http://yahoo.com")); // missing
			assertFalse(url.isValid("http://bad data.yahoo.com")); // space (bad)
		}
		
		@Test
		public void partition_get_and_files(){
			assertTrue(url.isValid("http://www.yahoo.com/")); // root
			assertTrue(url.isValid("http://www.yahoo.com/level1.html")); // 1st level file
			assertTrue(url.isValid("http://www.yahoo.com/level1/level2.html")); // 2nd level file
			assertFalse(url.isValid("http://www.yahoo.com/level1//")); // invalid file path
			assertFalse(url.isValid("http://www.yahoo.com/level1/./../")); // invalid file path
			assertTrue(url.isValid("http://www.yahoo.com?data1=data1")); // single get variable
			assertTrue(url.isValid("http://www.yahoo.com?data1=data1&data2=data2")); // two get variables
			assertFalse(url.isValid("http://www.yahoo.com?data1data1")); // invalid get variable
		}

   }
   
   
   
   
   
   public void testIsValid()
   {
	   for(int i = 0;i<10000;i++)
	   {
		   
	   }
   }
   
   public void testAnyOtherUnitTest()
   {
	   
   }
   /**
    * Create set of tests by taking the testUrlXXX arrays and
    * running through all possible permutations of their combinations.
    *
    * @param testObjects Used to create a url.
    */
   

}
